﻿@using ZX.Tools
@using ZX.Model
@model ZX.Model.Project_Task
@{
    ViewBag.Title = "完成-指效OA";
    int userId = Session["UserId"].ToInt();
}
<link href="~/dist/lib/datetimepicker/datetimepicker.min.css" rel="stylesheet" />
<link href="/Scripts/layui/css/layui.css" rel="stylesheet" />

<script src="~/Scripts/layer/layer.js"></script>
<script src="~/Scripts/layer/layer.tools.js"></script>
<script src="/Scripts/layui/layui.js"></script>
<script src="~/dist/lib/datetimepicker/datetimepicker.min.js"></script>

<form id="doTaskForm" method="post" class="form-horizontal" style="padding-top: 38px;" action="/Project_Task/FinishSave">
    <input type="hidden" id="Id" name="Id" value="@Model.Id">
    <input type="hidden" id="TExpected" name="TExpected" value="@Model.TExpected">
    <input type="hidden" id="FK_ProjectId" name="FK_ProjectId" value="@Model.FK_ProjectId">
    <input type="hidden" id="secondMenuId" name="secondMenuId" value="@ViewBag.SecondMenuId" />
    <input type="hidden" name="ParentId" value="@Model.ParentId" />


    <div class="form-group">
        <label for="ConsumTime" class="col-sm-2">
            总消耗
        </label>
        <div class="col-md-6 col-sm-10">
            <div class="input-group">
                <input id="ConsumTime" name="ConsumTime" value="@ViewBag.ConsumTime" class='form-control' placeholder="例如:3" onkeypress="$.admin.keyPress(this)"
                       onkeyup="$.admin.keyUp(this)"
                       onblur="$.admin.keyBlur(this)" />
                <span class="input-group-addon ">小时</span>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label for="Assigned" class="col-sm-2">指派给</label>
        <div class="col-md-6 col-sm-10">
            <select name="Assigned" id="Sel_Assigned" class="form-control">
                <option value="" data-keys=""></option>
                @{
                    try
                    {
                        List<SelectListItem> selectItemsAssigned = ViewBag.ListTeam;
                        foreach (var item in selectItemsAssigned)
                        {
                            if (Model.Assigned.ToInt() > 0)
                            {
                                if (Model.Assigned == item.Value)
                                {
                                    <option value="@item.Value" data-keys="@item.Value" selected>@item.Text</option>
                                    continue;
                                }
                                <option value="@item.Value" data-keys="@item.Value">@item.Text</option>
                            }
                            else
                            {
                                <option value="@item.Value" data-keys="@item.Value">@item.Text</option>
                            }
                        }
                    }
                    catch { }
                }
            </select>
        </div>
    </div>
    <div id="StartTime" class="form-group">
        <label for="ActualStart" class="col-sm-2">
            完成时间
        </label>
        <div class="col-md-6 col-sm-10">
            <input type="text" name="TSucTime" class="form-control form-datetime" placeholder="选择一个日期+时间：yyyy-MM-dd hh:mm" readonly="readonly">
        </div>
    </div>

    <div class="form-group">
        <label for="LogRemark" class="col-sm-2">
            描述
        </label>
        <div class="col-md-6 col-sm-10">
            <textarea name="LogRemark" id="LogTextRemark" class='form-control' rows='5' placeholder="描述"></textarea>
        </div>
    </div>
    <div id="div_Attach" class="form-group">
        <label for="Attach" class="col-sm-2">
            附件
        </label>
        <div class="col-md-6 col-sm-10">
            <input type="hidden" value="" name="Attach" id="Attach" />
            <button type="button" class="layui-btn" id="btnUpload">上传附件</button><label id="lblAttach"></label>
        </div>
    </div>
    @{
        try
        {

            bool bl = true;
            //判断是否指派或者自己创建
            if (Model.Assigned == (userId + "") || Model.CreateUserId == userId)
            {
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        @Html.Raw(ViewBag.CurrentBtnList29)
                    </div>
                </div>
                bl = false;
            }
            //是否已经开放权限，如没有，继续走角色设定权限
            if (bl)
            {

                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        @Html.Raw(ViewBag.CurrentBtnList29)
                    </div>
                </div>
            }
        }
        catch { }
    }

</form>
<script type="text/javascript">

    // 选择时间和日期
    $(".form-datetime").datetimepicker(
        {
            weekStart: 1,
            todayBtn: 1,
            autoclose: 1,
            todayHighlight: 1,
            startView: 2,
            forceParse: 0,
            showMeridian: 1,
            format: "yyyy-mm-dd hh:ii"
        });

    $(function () {
        layui.use('upload', function () {
            var upload = layui.upload;
            var uploadInst1 = upload.render({
                elem: '#btnUpload'
                , url: '/upload/UploadAttach'
                , accept: 'file'
                , data: { direName: "/Task/Files" }
                , done: function (res) {

                    $("#Attach").val(res.Data);

                    $("#lblAttach").text(res.Data);

                }
                , error: function (res) {
                    win.alert(JSON.stringify(res));
                }
            });
        });
    });

   
    function saveData() {
        $("#doTaskForm").submit();
    }

    $("#doTaskForm").Validform({
        tiptype: 3,
        callback: function (form) {
            win.showLoading("正在保存...");
            $("#doTaskForm").ajaxSubmit(function (data) {
                if (data.Code == 300) {
                    win.alert("保存失败");
                } else if (data.Code == 200) {
                    win.success("保存成功", function () {
                        win.hideLoading();
                        window.parent.location.reload();//刷新当前页面.
                        win.close();
                    });
                }
            });
            return false;
        }
    });
</script>
